﻿<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:asp="remove">

	<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>

  <xsl:variable name="shift-width" select="10" />
	<xsl:variable name="img-directory" select='"~/_layouts/images/Rzrlf.SP.Innovator.WebParts/"' />

  <xsl:template match="/SOAP-ENV:Envelope/SOAP-ENV:Body/Result">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
          <xsl:apply-templates select="Item">
            <xsl:with-param name="depth" select="1"/>
          </xsl:apply-templates>
        </td>
      </tr>
    </table>
  </xsl:template>

  <xsl:template match="Item">
    <xsl:param name="depth" />
	<xsl:variable name="commonId" select="generate-id()" />
    <xsl:variable name="id" select="id" />
    <xsl:variable name="itemNo" select="item_number" />
    <xsl:variable name="rev" select="major_rev" />
    <xsl:variable name="relUrl" select="url_workspace" />
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <xsl:if test="$depth>1">
          <td width="{$shift-width}"></td>
        </xsl:if>
        <td valign="top">
          <img id="img{$commonId}" src="{$img-directory}Collapse8x8.png" onclick="toggle(this)" />
          <xsl:if test="$relUrl != ''">
            <asp:ImageButton runat="server" imageurl="~/_layouts/images/Rzrlf.SP.Innovator.WebParts/SPSite.png" tooltip="Navigate to part-centric workspace" PostBackUrl="http://cpd2010/{$relUrl}" />
          </xsl:if>
          <asp:LinkButton runat="server" commandargument="{$id}" commandname="get" text="{$itemNo} - {$rev}" />
          <div id="div{$commonId}">
            <xsl:attribute name="style">display:block;</xsl:attribute>
            <xsl:apply-templates select="Relationships/Item/related_id/Item">
              <xsl:with-param name="depth" select="$depth+1" />
            </xsl:apply-templates>
          </div>
        </td>
      </tr>
    </table>
  </xsl:template>

</xsl:stylesheet>